<?php
namespace Asset\Controller;

use Base\Controller\AdminBaseController;

class TemplateController extends AdminBaseController{
	
	public function _initialize() {
		parent::_initialize();
	}
	
	/******************************** JSON *********************************/
	/** getAllTheme4Admin  */
    public function getAllTheme4Admin() {												// BUG: can not find all themes +++
		$tpls = sp_scan_dir(C("SP_TMPL_PATH") . "*", GLOB_ONLYDIR);
		$noneed = array(".", "..", ".svn");
		$themeList = array_diff($tpls, $noneed);
// 		dump($themeList);
		
	    // return
	    $this->ajaxReturn($themeList);
	}
	
	/** getAllTpl4Cat  */
    public function getAllTpl4Cat() {
		$template_path = C("SP_TMPL_PATH") . C("SP_DEFAULT_THEME") . "/Content/";
		$files = sp_scan_dir($template_path . "*");
		$suffix = C("TMPL_TEMPLATE_SUFFIX");
		$tplFileList = array();
		foreach ($files as $f) {
			if ($f != "." && $f != ".." && is_file($template_path . $f) && preg_match("/$suffix$/", $f)) {				// $f != "." || $f != ".." ??? kk++
				$tplFileList[] = str_replace($suffix, "", $f);
			}
		}
// 		dump($tplFileList);
		
	    // return
	    $this->ajaxReturn($tplFileList);
	}
}